﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyDB;
using MyClassLibrary;

namespace MyProgram
{
    public partial class FrmJBTAdd : FrmBaseModify
    {
        public FrmJBTAdd()
        {
            InitializeComponent();
        }

        internal string Divname;

        MedicareDataClassesDataContext db = new MedicareDataClassesDataContext();

        private void FrmJBTAdd_Load(object sender, EventArgs e)
        {
            this.label3.Text = Divname;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            JobTitles div = new JobTitles {  職稱 = this.textBox1.Text };

            if (this.label3.Text == "")
            {
                db.JobTitles.InsertOnSubmit(div);
            }
            else
            {
                var q = (from f in db.JobTitles
                         where f.職稱 == this.label3.Text
                         select f).First();

                q.職稱 = this.textBox1.Text;

            }

            db.SubmitChanges();

            this.Close();
        }
    }
}
